using System;
using System.Runtime.InteropServices;
namespace BMC.ARSystem
{
	[ClassInterface, Guid("80288c3e-b472-4710-a5df-1bdf9b9fe3bc"), ProgId("BMC.ARSystem.Reference")]
	public class Reference
	{
		[ARStructMemTypeInfo(Name = "label", Offset = 0u)]
		private string _label;
		[ARStructMemTypeInfo(Name = "description", Offset = 1u)]
		private string _description;
		[ARStructMemTypeInfo(Name = "type", Offset = 2u)]
		private int _referenceType;
		private string _name;
		public string Label
		{
			get
			{
				return this._label;
			}
			set
			{
				this._label = value;
			}
		}
		public string Description
		{
			get
			{
				return this._description;
			}
			set
			{
				this._description = value;
			}
		}
		public int ReferenceType
		{
			get
			{
				return this._referenceType;
			}
			set
			{
				this._referenceType = value;
			}
		}
		public string Name
		{
			get
			{
				return this._name;
			}
			set
			{
				this._name = value;
			}
		}
		private Reference()
		{
			this.Label = (this.Description = "");
		}
		public Reference(int typ, string name) : this()
		{
			this.ReferenceType = typ;
			this.Name = name;
		}
		public Reference(int typ) : this(typ, "")
		{
		}
		internal Reference(object rawData, Server server)
		{
			int[] indexSpec = new int[1];
			this.Label = (string)Util.GetAt(rawData, indexSpec);
			this.Description = (string)Util.GetAt(rawData, new int[]
			{
				1
			});
			this.ReferenceType = Convert.ToInt32(Util.GetAt(rawData, new int[]
			{
				2
			}));
		}
		internal static Reference createInstance(object[] rawData, Server server)
		{
			int[] array = new int[2];
			array[0] = 3;
			Reference reference;
			switch (Convert.ToInt32(Util.GetAt(rawData, array)))
			{
			case 1:
				reference = new ExternalReference(rawData, server);
				return reference;
			}
			reference = new Reference(rawData, server);
			reference.Name = (string)Util.GetAt(rawData, new int[]
			{
				3,
				1
			});
			return reference;
		}
		internal static object ToVariant(object given, Server server)
		{
			Reference reference = given as Reference;
			if (reference == null)
			{
				return given;
			}
			object[] array = new object[4];
			array[0] = ARTypeMgr.Instance.toVariant(reference.Label);
			array[1] = ARTypeMgr.Instance.toVariant(reference.Description);
			array[2] = ARTypeMgr.Instance.toVariant(reference.ReferenceType);
			if (reference is ExternalReference)
			{
				ExternalReference externalReference = reference as ExternalReference;
				array[3] = new object[]
				{
					1,
					new object[]
					{
						ARTypeMgr.Instance.toVariant(externalReference.PermittedGroups),
						Util.ConvertToARValue(externalReference.Value)
					}
				};
			}
			else
			{
				Reference reference2 = reference;
				array[3] = new object[]
				{
					0,
					ARTypeMgr.Instance.toVariant(reference2.Name)
				};
			}
			return array;
		}
		public override bool Equals(object obj)
		{
			Reference reference = obj as Reference;
			if (reference == null)
			{
				return base.Equals(obj);
			}
			return string.Compare(this._label, reference._label) == 0 && string.Compare(this._description, reference._description) == 0 && this._referenceType == reference._referenceType && string.Compare(this._name, reference._name) == 0;
		}
		public override int GetHashCode()
		{
			return this._referenceType + this._label.GetHashCode();
		}
	}
}
